import UDP_utils
from PIL.Image import *
from time import sleep

def main():

    while True:
        # 创建一个截图
        img = UDP_utils.Image()
        img.grabImage()      # 获取截图
        img.image2bytes()    # 转换为bytes
        img.bytes2compress() # 压缩

        # 创建一个发送对象
        sender = UDP_utils.SendImage(img, ('255.255.255.255', 22222))
        sender.sendStart()
        sender.sendImage()
        sender.sendOver()
        sleep(0.5)


if __name__ == '__main__':
    main()